package o;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import com.huawei.appgallery.packagemanager.api.bean.ManagerTask;

public class cpf extends Handler {
    private static final Object ˊ = new Object();
    private static cpf ॱ;
    private Context ˎ;

    public static cpf ˋ(Context context) {
        cpf o_cpf;
        synchronized (ˊ) {
            if (ॱ == null) {
                ॱ = new cpf(context);
            }
            o_cpf = ॱ;
        }
        return o_cpf;
    }

    public cpf(Context context) {
        super(context.getMainLooper());
        this.ˎ = context.getApplicationContext();
    }

    public void ॱ(int i, ManagerTask managerTask) {
        ॱ(i, managerTask, 0);
    }

    public void ॱ(int i, ManagerTask managerTask, int i2) {
        if (!(managerTask == null || cop.ˊ == null)) {
            cop.ˊ.ˊ(i, managerTask.packageName);
        }
        Message obtainMessage = obtainMessage();
        obtainMessage.obj = managerTask;
        obtainMessage.arg1 = i;
        obtainMessage.arg2 = i2;
        sendMessage(obtainMessage);
    }

    public void handleMessage(Message message) {
        if (message != null) {
            Object obj = message.obj;
            if (obj instanceof ManagerTask) {
                Object obtainMessage;
                ManagerTask managerTask = (ManagerTask) obj;
                if (managerTask.ˋ != null) {
                    obtainMessage = managerTask.ˋ.obtainMessage();
                } else {
                    obtainMessage = Message.obtain();
                }
                obtainMessage.obj = obj;
                obtainMessage.arg1 = message.arg1;
                obtainMessage.arg2 = message.arg2;
                Intent intent = new Intent("PackageManager.action.PACKAGE_MSG_DISPATCH");
                intent.putExtra("PackageManager.extra.PARCELABLE_MESSAGE", obtainMessage);
                ll.ˏ(this.ˎ).ˎ(intent);
                if (managerTask.ˋ != null) {
                    managerTask.ˋ.sendMessage(obtainMessage);
                }
                int i = message.arg1;
                int i2 = message.arg2;
                if (managerTask.ॱ != null) {
                    new cpd(managerTask, i, i2).execute(new Void[0]);
                }
            }
        }
    }
}
